﻿<%@ Page Title="Lar São José" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="Idosos.aspx.cs" Inherits="LarDosIdosos.Idosos" %>
<%@ Register Assembly="LarDosIdosos" TagPrefix="asc" Namespace="LarDosIdosos" %>
<%@ Register Src="~/WebUserControlIdoso.ascx" TagName="webUserControlIdoso" TagPrefix="asc" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div class="divPrincipal">
    <div class="divCentralizadora">
        <asp:UpdatePanel ID="updatePanelIdosos" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:Panel ID="panelIdosos" runat="server" >
                    <div class="buttonCad">
		                    <asp:Button ID="buttonCadastrar" runat="server" OnClick="buttonCadastrar_OnClick" Text="Cadastrar"/>
						</div>
						<div class="divConsulta">
		                    <asp:TextBox id="textBoxConsulta" runat="server" Text=""></asp:TextBox><asp:ImageButton ID="imageButtonConsulta" ImageUrl="~/Imagens/lupaVisualizarRegistro.png" Width="20px" runat="server" OnClick="buttonConsulta_OnClick"/>
						</div>
                    <asc:GridViewCustom
                        ID="gridViewIdosos"
                        runat="server"
					    Width="100%"
                        AutoGenerateColumns="False"
                        AllowSorting="True"
                        CssClass="tablestyle"
                        OnDataBound="gridViewIdosos_DataBound"
                        OnRowDataBound="gridViewIdosos_OnRowDataBound"
                        OnRowCommand="gridViewIdosos_OnRowCommand"
                        DataSourceID="dataSourceIdosos"
                        AllowPaging="True"
				        BackColor="#E9E9E9"
				        GridLines="None"
                        OnSorted="gridViewIdosos_OnSorted"
                        OnPageIndexChanged="gridViewIdosos_OnPageIndexChanged"
                        CellPadding="4"
                        >
                        <AlternatingRowStyle BackColor="#f7f7f7"/>
				        <HeaderStyle BackColor="#EEEEEE" ForeColor="Black" />
					    <RowStyle Height="50px" BackColor="#FFFFFF"/>
                        <EmptyDataRowStyle BackColor="#F7F7F7" Height="300px" VerticalAlign="Middle" HorizontalAlign="Center" />
                        <EmptyDataTemplate >
                            Nenhum Resultado Encontrado
                        </EmptyDataTemplate>                                                                              
                    
                        <Columns>
                            <asp:TemplateField HeaderStyle-Width="1%" ShowHeader="false">
					            <ItemTemplate>
                                    <asp:HiddenField ID="hiddenFieldId" runat="server" Value='<%# Eval("Codigo_Idoso") %>' />
				                </ItemTemplate>
				            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Nome" SortExpression="Nome_Idoso">
				                <ItemTemplate> 
				                    <asp:Label ID="labelNomeDoIdoso" runat="server" Text='<%# Eval("Nome_Idoso") %>' ></asp:Label>
				                </ItemTemplate>
				                <headerstyle Width="15%"/>
				            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Funcionario">
				                <ItemTemplate> 
				                    <asp:Label ID="labelFuncionario" runat="server" Text='<%# Eval("Funcionario.Nome_Funcionario") %>' ></asp:Label>
				                </ItemTemplate>
				                <headerstyle Width="10%"/>
				            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Estado Civil">
				                <ItemTemplate> 
				                    <asp:Label ID="labelEstadoCivil" runat="server" Text='<%# Eval("Estado_Civil.Nome_Estado_Civil") %>' ></asp:Label>
				                </ItemTemplate>
				                <headerstyle Width="10%"/>
				            </asp:TemplateField>
				            <asp:TemplateField HeaderText="Data de Nascimento" SortExpression="Data_de_Nascimento">
				                <ItemTemplate> 
				                    <asp:Label ID="labelDataDeNascimento" Runat="Server" Text='<%# Eval("Data_de_Nascimento", "{0:dd/MM/yyyy}") %>' />
				                </ItemTemplate>
				                <headerstyle Width="10%"/>
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                            <asp:BoundField ItemStyle-Width="10%" DataField="CPF_Idoso" HeaderText="CPF" />
                            <asp:BoundField ItemStyle-Width="10%" DataField="RG_Idoso" HeaderText="RG" />
                            <asp:TemplateField HeaderText="Relatório de Encaminhamento">
				                <ItemTemplate> 
				                    <asp:ImageButton ID="imageButtonBaixarRelatorioDeEncaminhamento" runat="server" OnClientClick='<%# "abrirDocumento(\"./Arquivos/Arquivo.ashx?relatorio=" + Eval("Codigo_Idoso") + "\");" %>' ImageUrl="~/Imagens/imageBaixarRelDeEnc.png" />
				                </ItemTemplate>
				                <headerstyle Width="10%"/>
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                            <asp:TemplateField>
				                <ItemTemplate> 
				                      <asp:ImageButton Visible="true" ID="imageButtonVisualizar" Runat="Server" ToolTip="Visualizar registro"  ImageUrl="~/Imagens/lupaVisualizarRegistro.png" CommandName="visualizar" CommandArgument='<%# ((GridViewRow) Container).RowIndex %>'/>	
                                      <asp:ImageButton Visible="false" ID="imageButtonEditar" Runat="Server" ToolTip="Editar registro"  ImageUrl="~/Imagens/lapisEditarRegistro.png"  CommandName="editar" CommandArgument='<%# ((GridViewRow) Container).RowIndex %>'/>	
                                      <asp:ImageButton Visible="false" ID="imageButtonExcluir" Runat="Server" ToolTip="Excluir registro"  ImageUrl="~/Imagens/ExcluirRegistro.png"  CommandName="excluir" CommandArgument='<%# ((GridViewRow) Container).RowIndex %>'/>				             
				                </ItemTemplate>
                            <headerstyle Width="10%"/>
                            <ItemStyle VerticalAlign ="Middle" HorizontalAlign="Center" />
                        </asp:TemplateField>
                        </Columns>
                        <PagerTemplate>
                                <table width="100%" >
                                <tr>
                                    <td style="text-align:  left">
                                        Page Size: 
                                        <asp:DropDownList ID="ddPageSize" runat="server" EnableViewState="true" OnSelectedIndexChanged="ddPageSize_SelectedIndexChanged" AutoPostBack="true">
                                            <asp:ListItem Text="10" ></asp:ListItem>
                                            <asp:ListItem Text="15" ></asp:ListItem>
                                            <asp:ListItem Text="20" ></asp:ListItem>
                                            <asp:ListItem Text="25" ></asp:ListItem>
                                            <asp:ListItem Text="30" ></asp:ListItem>
                                            <asp:ListItem Text="35" ></asp:ListItem>
                                            <asp:ListItem Text="40" ></asp:ListItem>
                                            <asp:ListItem Text="45" ></asp:ListItem>
                                            <asp:ListItem Text="50" ></asp:ListItem>
                                        </asp:DropDownList>
                                    </td>
                                    <td style="text-align: right">
                                        <asp:Label ID="lblPageCount" runat="server"></asp:Label>
                                    </td>
                                </tr>
                            </table>
                        </PagerTemplate>
                        </asc:GridViewCustom>                        
                    <div style="margin-top:5px">
                        <asp:DataPager  ID="pagerIdosos" PageSize="10" runat="server" PagedControlID="gridViewIdosos">
                            <Fields>                                            
                                <asp:NextPreviousPagerField FirstPageText="&lt;&lt;" LastPageText="&gt;&gt;" 
                                    NextPageText="&gt;"  PreviousPageText="&lt;" ShowFirstPageButton="True"
                                    ShowNextPageButton="False" ButtonCssClass="datapager" />
                                <asp:NumericPagerField ButtonCount="10"  NumericButtonCssClass="datapager" CurrentPageLabelCssClass="datapager"   />
                                <asp:NextPreviousPagerField LastPageText="&gt;&gt;" NextPageText="&gt;" 
                                    ShowLastPageButton="True" ShowPreviousPageButton="False" ButtonCssClass="datapager" />
                            </Fields>
                        </asp:DataPager>
                    </div>
                </asp:Panel>
        
                 
                <br />
                <asp:ObjectDataSource ID="dataSourceIdosos" runat="server" 
                    SelectMethod="BuscaIdosos" TypeName="LarDosIdosos.DataSources.DataSourceIdoso" 
                    EnablePaging="True" SelectCountMethod="TotalDeIdosos" 
                    SortParameterName="sortExpression">
                    <SelectParameters>
                        <asp:Parameter DefaultValue="select * from idoso" Name="sql" Direction="Input" />
                    </SelectParameters>                                            
                </asp:ObjectDataSource>

                
                <asp:Panel ID="panelVisualizarIdoso" runat="server" Visible="false">
                    
                    <div style="float:right">
                        <asp:LinkButton ID="linkButtonVoltar" runat="Server" OnClick="linkButtonVoltar_OnClick">Voltar</asp:LinkButton>
                    </div>
                    <asc:WebUserControlIdoso ID="webUserControlIdoso" runat="server" />
                </asp:Panel>
            </ContentTemplate>
			<Triggers>
				<asp:PostBackTrigger ControlID="gridViewIdosos" />
                <asp:AsyncPostBackTrigger ControlID="imageButtonConsulta" EventName="Click" />
			</Triggers>
      	</asp:UpdatePanel>
    </div>
</div>
</asp:Content>
